<?php 
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
$kq='';
try{
include '../connection/connection_checkhinh.php';
if($connectioncheckhinh){
	set_time_limit(0);
	include 'showscreen.php';
	$idmonitor = $_REQUEST['monitorid'];
	$winW = $_REQUEST['winW'];
	$winH = $_REQUEST['winH'];
	$numb= $_REQUEST['numb'];
	$bd=$_REQUEST['bd'];
	$kt=$_REQUEST['kt'];
	$cot=1;
	if($numb==0){
		$query1 = 'SELECT nCamera FROM monitor m WHERE m.Monitor_ID='.$idmonitor;
		$result = mysql_query($query1,$connectioncheckhinh);
		while( $row=mysql_fetch_array($result) ){
			$cot=$row['nCamera']+1;
			$numb=$cot * $cot;
		}
		mysql_free_result($result);
	}else{
		$cot=sqrt($numb);
	}
	$query = 'SELECT cardis.`host`,cardis.filename,cardis.car_datetime,cardis.id,cardis.`name`,fa.pos as posfav,confc.camera_type,confc.lens_type,confc.trigger_type,mn.nCamera as slCamera,mn.timeOut FROM monitor mn, favourite fa,
		 cardisplay cardis,configcamera confc 
		WHERE mn.Monitor_ID = fa.monitor_ID AND cardis.id = confc.id 
		AND fa.camera_ID = cardis.id AND mn.Monitor_ID = '.$idmonitor.' ORDER BY fa.pos ASC';
	$selectpos = mysql_query($query,$connectioncheckhinh);
	$mang=array();
	$mang=$_SESSION['mcar'];
	while( $row=mysql_fetch_array($selectpos) ){ 
		$ob= new showscreen();
		$ob->Instance(chop($row['posfav']), chop($row['filename']),chop($row['host']), chop($row['car_datetime']), chop($row['camera_type']), chop($row['lens_type']), chop($row['name']), chop($row['id']), chop($row['trigger_type']), chop($row['timeOut']));
		$_SESSION['mcar'][chop($row['posfav'])]=$ob;
	}
	mysql_free_result($selectpos);
	mysql_close($connectioncheckhinh);
	for($i=$bd;$i<$kt;$i++){
			$CT = unserialize (serialize ($_SESSION['mcar'][$i+1]));
			$CT1 = unserialize (serialize ($mang[$i+1]));
			if($CT->car_datetime!=$CT1->car_datetime){
				if($kq==''){
					$kq=$i+1;
				}else{
					$kq .="-".($i+1);
				}
			}else if($CT->light!=$CT1->light){
				if($kq==''){
					$kq=$i+1;
				}else{
					$kq .="-".($i+1);
				}
			}
	}
}
}catch(Exception $e){
	//echo $e->getMessage();
}
?>
<input type="hidden" id="carlist" name="carlist" value="<?=$kq?>" />